package clientGUI;

import javax.swing.JPanel;
import java.awt.Dimension;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.border.LineBorder;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.ImageIcon;

import librarianPanels.SearchABookPanel;

/**
 * @author Shay
 * Creating user GUI
 */
public class UserGUI extends JPanel 
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private final static UserGUI lGUI=null;
	private JButton canceledButton;
	private JButton btnOrderBook;
	private JButton btnLogout;
	public static UserGUI getInstance()
	{
		if(lGUI==null)
			return new UserGUI();
		return lGUI;
	}
	
	private UserGUI() 
	{
		canceledButton=new JButton();
		setBorder(new LineBorder(new Color(0, 0, 0), 3, true));
		setPreferredSize(new Dimension(219, 547));
		setLayout(null);
		
		btnOrderBook = new JButton("Search");
		btnOrderBook.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				SearchABookPanel p = new SearchABookPanel();
				MainGUI.middlePanelChange(p);	
				canceledButton.setEnabled(true);
				canceledButton=btnOrderBook;
				canceledButton.setEnabled(false);
			}
		});
		btnOrderBook.setBounds(10, 13, 199, 41);
		add(btnOrderBook);
		
		btnLogout = new JButton("Login");
		canceledButton=btnLogout;
		canceledButton.setEnabled(false);
		btnLogout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				LoginPanel p=new LoginPanel();
				MainGUI.middlePanelChange(p);
				canceledButton.setEnabled(true);
				canceledButton=btnLogout;
				canceledButton.setEnabled(false);
			}
		});
		btnLogout.setBounds(10, 482, 199, 41);
		add(btnLogout);
		
		JLabel label = new JLabel("");
		label.setIcon(new ImageIcon("images/book3.jpg"));
		label.setBounds(3, 3, 215, 540);
		label.setBackground(new Color(0,0,0,0));
		add(label);
		
	}
}
